package com.asteroid20.dao.imp1;

import com.asteroid20.Account;

import java.io.BufferedWriter;
import java.io.FileWriter;
import java.io.IOException;
import java.time.*;


public class LoginDaoImp1 implements LoginDao {
    public void play(Account account)  {
        if(true){
            LocalDateTime time =LocalDateTime.now();
            BufferedWriter writer = null;
            try {
                writer = new BufferedWriter(new FileWriter("src/main/resources/account-list/account.txt", true));
                writer.write("["+time+"]"+"account:"+account.account+" "+"password:"+account.password);
                writer.newLine();
                writer.close();
            } catch (IOException e) {
                BufferedWriter debuglogs = null;
                try {
                    debuglogs = new BufferedWriter(new FileWriter("src/main/resources/account-list/debuglogs.txt", true));
                    debuglogs.write("["+time+"]"+"account:"+account.account+" "+"password"+account.password+"写入错误");
                    writer.newLine();
                    throw new RuntimeException(e);
                } catch (IOException ex) {
                    throw new RuntimeException(e);
                }

            }
        }
        else{
            System.err.println("格式错误");
        }

    }
}
